$(() => {
    layui.use(function () {
        const laydate = layui.laydate;
        laydate.render({
            elem: "#birthday",
            type: "date"
        });
    });
});

function submit(cb = $.noop) {
    let class_name = $("#class_name").val();
    let begin_time = $("#begin_time").val();
    let end_time = $("#end_time").val();
    let major_id = $("#major_id").val();
    let student_cnt = $("#student_cnt").val();
    let status = $("#status").val();
    let description = $("#description").val();


    //前端校验：js校验
    if (class_name.trim() === "") {
        layer.msg("姓名不可为空");
        return;
    }


    $.ajax({
        url: ctx + "/admin/classes/add",
        method: "post",
        data: {
            class_name,
            begin_time,
            end_time,
            major_id,
            student_cnt,
            status,
            description
        },
        success(resp) {
            cb(resp.success);
        }
    });


}